package com.ruoyi.web.controller.gift;


import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.gift.domain.GiftRecord;
import com.ruoyi.gift.service.IGiftRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 礼金记录Controller
 *
 * @author ruoyi
 * @date 2025-09-29
 */
@Api("礼金信息管理")
@RestController
@RequestMapping("/gift/record")
public class GiftRecordController extends BaseController {
    @Autowired
    private IGiftRecordService giftRecordService;

    /**
     * 查询礼金记录列表
     */
    @ApiOperation("获取礼金信息")
//    @PreAuthorize("@ss.hasPermi('system:record:list')")
    @GetMapping("/list")
    public TableDataInfo list(GiftRecord giftRecord) {
        startPage();
        List<GiftRecord> list = giftRecordService.selectGiftRecordList(giftRecord);
        return getDataTable(list);
    }

    /*


     *//**
     * 导出礼金记录列表
     *//*
    @PreAuthorize("@ss.hasPermi('system:record:export')")
    @Log(title = "礼金记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GiftRecord giftRecord) {
        List<GiftRecord> list = giftRecordService.selectGiftRecordList(giftRecord);
        ExcelUtil<GiftRecord> util = new ExcelUtil<GiftRecord>(GiftRecord.class);
        util.exportExcel(response, list, "礼金记录数据");
    }

    *//**
     * 获取礼金记录详细信息
     *//*
    @PreAuthorize("@ss.hasPermi('system:record:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(giftRecordService.selectGiftRecordById(id));
    }
*/
    /**
     * 新增礼金记录
     */
    @ApiOperation("新增礼金记录")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "name", value = "姓名", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "address", value = "地址", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "phone", value = "电话", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "giftDate", value = "日期", dataType = "LocalDate", dataTypeClass = LocalDate.class),
            @ApiImplicitParam(name = "giftAmount", value = "礼金", dataType = "BigDecimal", dataTypeClass = BigDecimal.class),
            @ApiImplicitParam(name = "giftAmountImage", value = "礼金记录图片", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "giftItem", value = "礼物", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "giftItemImage", value = "礼物图片", dataType = "String", dataTypeClass = String.class)
    })
//    @PreAuthorize("@ss.hasPermi('system:record:add')")
    @Log(title = "礼金记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GiftRecord giftRecord) {
        return toAjax(giftRecordService.insertGift(giftRecord));
    }

    /*  *//**
     * 修改礼金记录
     *//*
    @PreAuthorize("@ss.hasPermi('system:record:edit')")
    @Log(title = "礼金记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GiftRecord giftRecord) {
        return toAjax(giftRecordService.updateGiftRecord(giftRecord));
    }

    *//**
     * 删除礼金记录
     *//*
    @PreAuthorize("@ss.hasPermi('system:record:remove')")
    @Log(title = "礼金记录", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(giftRecordService.deleteGiftRecordByIds(ids));
    }*/
}

